<?php
        require_once('auth.php');
	//Grab all necessary data
	$currfile = $_SESSION['SESS_CURR_FILE'];
	$login = $_SESSION['SESS_LOGIN'];
	$currentdir = getcwd();
	$target = $currentdir."/workspace/".$login;
	$file = $target."/temp.redcat";
	$file = fopen($file, 'w');
	$data = $target."/rdc.txt";
	$data = fopen($data, "r");
	$currfile = file($currfile);	
	$error = $_SESSION['SESS_ERR'];

//Organize and write a temporary data file with the new RDC and error values to use as current session file
foreach($currfile as $line)
{
        $l1 = fgets($data);
        $calc = preg_split("/[\s]+/", $l1);
        $comment = preg_split('(\/\*)', $line);
        $value = preg_split("/[\s]+/", $comment[0]);
        $str = $value[0]." ".$value[1]." ".$value[2]." ".$value[3]." ".$value[4]." ".$value[5]." ".$calc[0]." ".$value[7]." ".$error." /*$comment[1]";
	fwrite($file, $str);
}
fclose($file);
fclose($data);
$_SESSION['SESS_CURR_FILE'] = $target."/temp.redcat";
header("location: return-upload.php");
session_write_close();
exit();
?>

